nest build does not generate the dist folder
문제정의
dist 폴더랑 node_modules 디렉터리를 제거한 뒤에 nest build
를 진행해도 dist 폴더 안에 main.js 파일이 생성되지 않는다. 하지만 Elastic Beanstalk 환경에서는 정상적으로 빌드가 되는 모습에 로컬과 무슨 차이점이 있는지 고민이 된다.
해결방법
https://stackoverflow.com/a/66771530/21369350
Had the same issue, the problem is TS compiler won't generate /dist
(compile JS to TS) if there're some .tsbuildinfo
files (when incremental
option is on).
So, basically what you need to do is remove all .tsbuildinfo
files before you build the project.
Or simply turn off the incremental
and noEmit
options in your tsconfig.json:
"noEmit": false // <- remove this or set to false
"incremental": false, // <- remove this or set to false
확인해보니..
내 프로젝트 폴더에서도 tsconfig.build.tsbuildinfo
파일이 존재했다. 이 파일을 지운 뒤 다시 build를 하니 정상적으로 main.js 파일이 생성되었다. 이 헛짓거리를 반복하지 않기 위해 package.json > scripts > build에 rm *tsbuildinfo
를 추가해야겠다.
{
"scripts": {
"prebuild": "rimraf dist *.tsbuildinfo",
}
}